The special GLOBAL variables (GLOBAL1 > GLOBAL10) are automatically declared within the script engine. You do not need to declare these yourself to use them. They are declared as
var GLOBAL1 : Variant;
var GLOBAL2 : Variant;
...
var GLOBAL10 : Variant;
The GLOBAL variables are global to each execution of a map, but they are not shared between maps (or even between different executions of the same map). Each map contains its own set of GLOBAL variables. Therefore if you have 2 maps and within one you set GLOBAL1 to 20, you will not be able to access this value through GLOBAL1 in the second map.
Since the GLOBAL variable is global to the map, you can set its value in one event and reference it from another. Therefore if within field 1 OnMap you set GLOBAL1 to 20, you can read this value from field 2 OnMap.
GLOBAL variables are naturally Persistent. This means it will retain its value for the entire execution of the map. However the next execution of the map will have its own set of GLOBAL variables will are initialised to null.
An example of using GLOBAL variables is
procedure ScriptEvent (var Value : variant);
begin
if Value > 10 then
GLOBAL1 := True
end;
procedure ScriptEvent (var Value : variant);
begin
if GLOBAL1 = True then
LogError('Something happened during execution and therefore this error is raised');
end;
The above two scripts form one example. In this example the GLOBAL1 variable is being used as a flag. Throughout the map checks are made and GLOBAL1 is set to true accordingly. A later event (potentially OnEndMap) checks the value of GLOBAL1 and depending on the flag sends an error message.